package com.huawei.appmarket.service.appdetail.view.widget;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
import com.huawei.appgallery.foundation.ui.framework.widget.button.DownloadButton;
import huawei.widget.HwTextView;
import o.cjz;
import o.Logger;
import o.epw;
import o.ewm.c;
import o.ewm.e;
import o.gg;

public class DetailDownloadButton extends DownloadButton {
    private d ʻ;
    private LayerDrawable ʼ;

    public interface d {
        void ʻ();
    }

    public DetailDownloadButton(Context context) {
        this(context, null);
    }

    public DetailDownloadButton(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, 0);
    }

    public DetailDownloadButton(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        ˋॱ();
        if (ˊॱ() != null) {
            ˊॱ().setAllCaps(false);
        }
    }

    public void ˊ() {
        if (ˊॱ() != null) {
            cjz.ˎ(ˊॱ());
            ((HwTextView) ˊॱ()).setGravity(17);
        }
    }

    public void setDownloadEventWatcher(d dVar) {
        this.ʻ = dVar;
    }

    public void onClick(View view) {
        if (ͺ()) {
            Logger.e("DetailDownloadButton", "PayStatusInvalid");
            return;
        }
        if (this.ʻ != null) {
            this.ʻ.ʻ();
        }
        super.onClick(view);
    }

    private void ˋॱ() {
        Drawable drawable = getResources().getDrawable(e.ʼॱ);
        gg.ॱ(gg.ʻ(getResources().getDrawable(e.ʿ)).mutate(), getResources().getColor(c.ᐝ));
        this.ʼ = new LayerDrawable(new Drawable[]{r1, drawable});
    }

    public void ai_() {
        super.ai_();
        if (ˏॱ() != null && this.ʼ != null) {
            ˏॱ().setProgressDrawable(this.ʼ);
        }
    }

    public void ʻ() {
        if (ˏॱ() != null && ˏॱ().getProgressDrawable() != null && ˊॱ() != null) {
            ˏॱ().getProgressDrawable().setAlpha(96);
            if (epw.ˏ()) {
                ˊॱ().setAlpha(0.38f);
            }
        }
    }

    public void ˎ() {
        super.ˎ();
        if (ͺ()) {
            setButtonDisable();
        }
    }

    private boolean ͺ() {
        return this.ˏ != null && this.ˏ.ᐝॱ() && TextUtils.isEmpty(this.ˏ.ॱˋ());
    }
}
